const routes = [
    {
        // 主页
        name: 'index',
        path: '/index',
        component: () => import('@/view/Index.vue')
    },
    {
        // 重定向到主页
        path: "/",
        redirect: '/index'
    },
    {
        // 投诉页
        path: '/report',
        name: 'report',
        component: () => import('@/view/main/Report.vue')
    },
    {
        // 注册页
        path: "/register",
        name: 'register',
        component: () => import('@/view/Register.vue')
    },
    {
        // 登录页
        path: '/login',
        name: 'login',
        component: () => import("../view/Login.vue")
    },
    {
        // TODO 未登录状态的路由守卫，其他地方也要做
        // 全部菜品页
        name: 'dishes',
        path: '/dishes',
        meta: {
            showFather: true,
        },
        component: () => import('@/view/main/Plates.vue'),
        children: [
            {
                // 分页面，查看菜品详情，此处包括餐品打分以及对餐品的用户评价
                name: 'dish',
                path: 'index/:dishId',
                meta: {
                    showFather: false,
                },
                component: () => import('@/view/main/SingleDish.vue')
            }
        ]
    },
    {
        // 展示全部都管理员发布的问卷调查
        name: 'surveys',
        path: '/surveys',
        component: () => import('@/view/main/Survey.vue')
    },
    {
        name: "surveyTest",
        path: "/survey/:surveyId",
        component: ()=>import('@/view/main/SurveyWrite.vue')
    },
    {
        // 展示全部食堂信息
        name: 'restaurants',
        path: '/restaurants',
        meta: {
            showFather: true,
        },
        component: () => import('@/view/main/Restaurants.vue'),
        children: [
            {
                // 单个食堂信息
                name: 'restaurant',
                path: 'index/:restaurantId',
                meta: {
                    showFather: false,
                },
                component: () => import('@/view/main/SingleRestaurant.vue')
            }
        ]
    },
    {
        // 展示用户动态
        name: 'community',
        path: '/Community',
        component: () => import('@/view/main/Community.vue')
    },
    // {
    //     // 展示用户Blog
    //     name: 'blog',
    //     path: '/blog',
    //     component: () => import('@/view/main/blog/main.vue')
    // },
         //展示树洞
    {
        name: 'holetree',
        path: '/holetree',
        component: () => import('@/view/main/HoleTree.vue')
    },
    {
        // 404资源未找到
        name: '404',
        path: '/404',
        component: () => import('@/view/common/HttpStatus404.vue')
    },
    {
        // 403权限不足
        name: '403',
        path: '/403',
        component: () => import('@/view/common/HttpStatus403.vue')
    },

    // 这里开始注意权限，没有权限就直接守卫到404

    // 系统管理员
    {
        path: '/top-manager',
        redirect: '/top-manager/index',
        meta: {title: '系统管理员'},
        // component: ()=>import('@/view/system-manager/Manager.vue'),
        children: [
            {
                // 系统管理员首页
                name: 'system-index',
                path: 'index',
                meta: {title: '首页'},
                component: () => import('@/view/system-manager/Manager.vue')
            },
            {
                // 食堂管理员分配
                name: 'auth-distribute',
                path: 'auth-distribute',
                meta: {title: '权限分配'},
                component: () => import('@/view/system-manager/AuthDistribute.vue')
            },
            {
                // 账户管理
                name: 'account-manage',
                path: 'account-manage',
                meta: {title: '账户管理'},
                component: () => import('@/view/system-manager/AccountManage.vue')
            },
            {
                // 控评
                name: 'remark-control',
                path: 'remark-control',
                meta: {title: '评论管理'},
                component: () => import('@/view/system-manager/RemarkControl.vue')
            },
            {
                // 交流社区信息监控
                name: 'community-surveillance',
                path: 'community-surveillance',
                meta: {title: '社区管理'},
                component: () => import("@/view/system-manager/CommunitySurveillance.vue")
            },
            {
                // 食堂信息管理
                name: 'manage-restaurant',
                path: 'manage-restaurant',
                meta: {title: '食堂管理'},
                component: () => import('@/view/system-manager/ManageRestaurant.vue')
            }
        ]
    },
    // 食堂管理员
    {
        path: '/restaurant-manager',
        redirect: '/restaurant-manager/index',
        meta: {title: '食堂管理员'},
        children: [
            {
                // 食堂管理员首页
                name: 'restaurant-index',
                path: 'index',
                meta: {title: '首页'},
                component: () => import('@/view/restaurant-manager/Manager.vue')
            },
            {
                // 食堂信息维护
                name: 'restaurant-info-maintain',
                path: 'restaurant-info-maintain',
                meta: {title: '餐厅信息'},
                component: () => import('@/view/restaurant-manager/RestaurantInfoMaintain.vue')
            },
            {
                // 菜品维护
                name: 'dishes-maintain',
                path: 'dishes-maintain',
                meta: {title: '菜品维护'},
                component: () => import('@/view/restaurant-manager/DishesMaintain.vue')
            },
            {
                // 发布投票调查
                name: 'vote',
                path: 'vote',
                meta: {title: '调查发布'},
                component: () => import('@/view/restaurant-manager/Vote.vue')
            },
            {
                // 回复本食堂菜品评价
                name: 'remark-reply',
                path: 'remark-reply',
                meta: {title: '评论回复'},
                component: () => import('@/view/restaurant-manager/RemarkReply.vue')
            },
            {
                // 最新推荐菜品发布（首页的那个滚动条，每个食堂一个菜）
                name: 'recommend-dish-publish',
                path: 'recommend-dish-publish',
                meta: {title: '新品发布'},
                component: () => import('@/view/restaurant-manager/RecommendDishPublish.vue')
            },
            {
                // 处理投诉信息
                name: 'report-reply',
                path: 'report-reply',
                meta: {title: '投诉回复'},
                component: () => import('@/view/restaurant-manager/ReportReply.vue')
            }
        ]
    },
    // 个人中心
    {
        path: '/self',
        redirect: '/self/index',
        children: [
            {
                path: 'index',
                name: 'self-index',
                component: () => import('@/view/common/SelfCenter.vue')
            }
        ]
    },
    // 组件样式测试
    {
        path: '/test',
        name: 'test',
        component: import("@/components/SurveyShowItem.vue")
    }
];

import {createRouter} from 'vue-router'
import {createWebHistory} from "vue-router";

const router = createRouter({
    history: createWebHistory(),
    // history: createWebHashHistory(),
    routes: routes
})

export default router